﻿Imports System
Imports System.Workflow.ComponentModel.Compiler

Namespace System.Workflow.ComponentModel
    Friend NotInheritable Class CancellationHandlerValidator
        Inherits CompositeActivityValidator
        ' Methods
        Public Overrides Function Validate(ByVal manager As ValidationManager, ByVal obj As Object) As ValidationErrorCollection
            Dim errors As ValidationErrorCollection = MyBase.Validate(manager, obj)
            Dim activity As CancellationHandlerActivity = [TryCast](obj,CancellationHandlerActivity)
            If (activity Is Nothing) Then
                Throw New ArgumentException(SR.GetString("Error_UnexpectedArgumentType", New Object() { GetType(CancellationHandlerActivity).FullName }), "obj")
            End If
            If (activity.EnabledActivities.Count = 0) Then
                errors.Add(New ValidationError(SR.GetString("Warning_EmptyBehaviourActivity", New Object() { GetType(CancellationHandlerActivity).FullName, activity.QualifiedName }), &H1A3, True))
            End If
            If (activity.AlternateFlowActivities.Count > 0) Then
                errors.Add(New ValidationError(SR.GetString("Error_ModelingConstructsCanNotContainModelingConstructs"), &H61F))
            End If
            Return errors
        End Function

    End Class
End Namespace

